package com.heima.wemedia;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.heima.apis.article.ArticleFeignClient;
import com.heima.apis.config.FeignConfiguration;
import com.heima.apis.schedule.TaskFeignClient;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;


@SpringBootApplication
@EnableDiscoveryClient
//@EnableFeignClients(basePackages = "com.heima.apis.article") //哪个微服务调用远程feign，就需要在该微服务的启动类上开启feign注解(并在其中指定feign接口的位置)
@EnableFeignClients(clients = {ArticleFeignClient.class, TaskFeignClient.class},defaultConfiguration = FeignConfiguration.class)
@EnableAsync//开启异步调用
@MapperScan("com.heima.wemedia.mapper")
@EnableScheduling
public class WemediaApplication {

    public static void main(String[] args) {
        SpringApplication.run(WemediaApplication.class,args);
    }

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
